<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('carte服务监控详情')" />
</head>
<body class="gray-bg">
<div class="alert alert-warning" id="alert_warning">
    <strong>节点信息有变动，自动更新!</strong>
</div>
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <input type="hidden" name="slaveId" th:value="${slaveId}">
                        <li>
                            <label>任务名称：</label>
                            <input type="text" name="taskName"/>
                        </li>
                        <li>
                            <select class="form-control m-b" name="datePicker">
                                <option value="1">全部</option>
                                <option value="2">近一天</option>
                                <option value="3">近一周</option>
                                <option value="4">近一个月</option>
                                <option value="5">近三个月</option>
                                <option value="6">近一年</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('busi:executionLog:edit')}]];
    var removeFlag = [[${@permission.hasPermi('busi:executionLog:remove')}]];
    var prefix = ctx + "busi/executionLog";
    var exeStatus = [[${@dict.getType('kt_exe_status')}]];
    var taskTypes = [[${@dict.getType('task_type')}]];
    var carteId = [[${carteId}]];

    $(function() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "任务调度日志",
            sortName: "startTime",
            sortOrder: "DESC",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '日志ID',
                    visible: false
                },
                {
                    field: 'taskName',
                    title: '任务名称',
                    formatter: function(value, row, index) {
                        return '<a href="javascript:void(0)" onclick="detail(\'' + row.id + '\')">' + value + '</a>';
                    }
                },
                {
                    field: 'startTime',
                    title: '开始时间'
                },
                {
                    field: 'endTime',
                    title: '结束时间'
                },
                {
                    field: 'executionMethod',
                    title: '执行方式'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(exeStatus, value);
                    }
                },
                {
                    field: 'taskType',
                    title: '任务类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(taskTypes, value);
                    }
                },
                {
                    field: 'remark',
                    title: '备注'
                }]
        };
        $.table.init(options);

        var _table = $.table;
        $("#alert_warning").hide();
        setInterval(function(){
            $.get("/getVersion","",function (data){
                if (window["updateState"]) {
                    if (window["updateState"]["carteMonitorDetail"] != data) {
                        _table.refresh()
                        $("#alert_warning").show();
                        setTimeout(function () {
                            $("#alert_warning").hide();
                        }, 5000);
                        window["updateState"]["carteMonitorDetail"] = data;
                    }
                } else {
                    window["updateState"] = {};
                    window["updateState"]["carteMonitorDetail"] = 1;
                }
            })
        }, 1000);
    });

    function detail(id) {
        var url = prefix + '/detail/' + id;
        $.modal.openTab("日志详细信息("+id+")", url);
    }

</script>
</body>
</html>